package com.znjb.myapplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.GridView;

import com.znjb.myapplication.adapter.MyGridVIewAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 刘亚飞 on 2017/3/16.
 */

public class Activity_AddItem extends Activity{
    private GridView gv1;

    private MyGridVIewAdapter adapter;
    private ArrayList<String> data;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add);
        initData();
        initView();
        adapter = new MyGridVIewAdapter(this);
        adapter.setDatas(data);
        gv1.setAdapter(adapter);
    }

    private void initData() {
        data = new ArrayList<>();

        data.add("首页");
        data.add("应用");
        data.add("游戏");
        data.add("专题");
        data.add("推荐");
        data.add("分类");
        data.add("热门");
        data.add("我的");
        data.add("最新");
        data.add("音乐");
        data.add("体育");
        data.add("美术");

    }

    private void initView() {
        gv1 = (GridView) findViewById(R.id.gv1);
    }

    @Override
    public void onBackPressed() {
        Intent intent = new Intent();
        Bundle bundle = new Bundle();
        bundle.putStringArrayList("list",data);
        intent.putExtras(bundle);
        setResult(201,intent);
        super.onBackPressed();
    }

    @Override
    protected void onDestroy() {
        Log.i("LYF===","删除");
        super.onDestroy();
    }
}
